package com.houtai.controller.job;


import com.houtai.authority.Authority;
import com.houtai.authority.AuthorityType;
import com.houtai.bean.TsJzAdmin;
import com.houtai.bean.dto.job.TdJobListDto;
import com.houtai.bean.dto.user.job.JobUserListDto;
import com.houtai.service.funcion.FuncionService;
import com.houtai.service.job.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by lizhun on 2017/7/19.
 */
@Controller
@RequestMapping(value = {"v5"})
public class JobController {
    @Resource
    private JobService jobService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Resource
    private FuncionService funcionService;
 
    /**
     * @Purpose  分页加载岗位
     * @version  1.0
     * @author   lizhun
     * @param    request
     * @return   RetInfo
     */
    @RequestMapping(value="/job/list")
    @Authority(AuthorityType.Login)
    public ModelAndView list(HttpServletRequest request, TdJobListDto page){
        ModelAndView mv = new ModelAndView("job/list");
        mv.addObject("retInfo", jobService.findTdJob(page, request));
        mv.addObject("token", request.getParameter("token"));
        mv.addObject("father_id", request.getParameter("father_id"));
        TsJzAdmin tsJzAdmin = (TsJzAdmin) redisTemplate.opsForValue().get(request.getParameter("token")) ;
        mv.addObject("funcions", funcionService.findSonFuncion(tsJzAdmin, Integer.valueOf(request.getParameter("father_id"))));
        return mv;
    }
    /**
     * @Purpose  分页加载岗位投递记录
     * @version  1.0
     * @author   lizhun
     * @param    request
     * @return   RetInfo
     */
    @RequestMapping(value="/user/job/list")
    @Authority(AuthorityType.Login)
    public ModelAndView user(HttpServletRequest request, JobUserListDto page){
        ModelAndView mv = new ModelAndView("job/user");
        mv.addObject("retInfo", jobService.jobUserList(page, request));
        mv.addObject("token", request.getParameter("token"));
        return mv;
    }

}
